package com.chixing.service.impl;

import com.chixing.mapper.CustomerMapper;
import com.chixing.pojo.Customer;
import com.chixing.service.UserService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private CustomerMapper customerMapper;
    @Override
    public ServerResponse save(Customer customer) {
        int rows = customerMapper.updateByPrimaryKey(customer);
        if (rows>0)
            return ServerResponse.saveSucccess(rows);
        else
            return ServerResponse.saveFail(null);
    }

    @Override
    public ServerResponse getById(Integer custId) {
        Customer customer = customerMapper.selectByPrimaryKey(custId);
        if (customer!=null)
            return ServerResponse.getSucccess(customer);
        return ServerResponse.getFail(null);
    }
}
